<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>

<%@page import="com.lovo.bbs.vo.*,com.lovo.bbs.bo.*,java.util.*"%>
	
<%
    //取得主题
    String  asTopicid = request.getParameter("topicid");
    int topicid=0;
    if(asTopicid!=null&&!"".equals(asTopicid)){
       topicid = Integer.parseInt(asTopicid);
    }
    TopicVo topicData = new TopicBo().getTopicInfo(topicid);
    
    //论坛列表
	ArrayList<ForumVo> forumList = (ArrayList<ForumVo>)application.getAttribute("forumList");
	String forumSelect = (String) request.getParameter("forumSelect");
	
    //请求页
	String queryPages = (String)request.getParameter("queryPage");
	if(queryPages==null||"".equals(queryPages)||"0".equals(queryPages)){
	  queryPages="1";
	}
	int queryPage=Integer.parseInt(queryPages);
	
	//操作类型
	String asOpType = (String)request.getParameter("opType");
	int opType = 0;
	if(!"".equals(asOpType)&&asOpType!=null){
	   opType = Integer.parseInt(asOpType);
	}
	
	String[] processMod = { "增加新主题", "修改主题", "删除主题" };
	Iterator it1;
%>
<html>
	<head>
		<link href="../../../css/admin.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="../../../js/wbs_admin.js"></script>
		<script type="text/javascript">
		    function validate(){
      	 
       	   var msg=document.getElementById("errormsg");
       	   
       	   if(trim(document.frmMain.topictitle.value)==""){            
              msg.innerHTML="<br><font color='red'>提示:请输入主题名称</font>"    
              document.frmMain.topictitle.focus();
              return false;
           }
       	   
       	   if(!isZore(document.frmMain.hits.value)){            
              msg.innerHTML="<br><font color='red'>提示:主题查看次数必须为数字</font>"    
              document.frmMain.hits.focus();
              return false;
           }
           
		   if(document.frmMain.hits.value>250||document.frmMain.hits.value<0){
              msg.innerHTML="<br><font color='red'>提示:主题查看次数范围为0~250</font>";
              document.frmMain.hits.focus();
              return false;
           }
           
            if(!isZore(document.frmMain.replynum.value)){            
              msg.innerHTML="<br><font color='red'>提示:主题回复次数必须为数字</font>"    
              document.frmMain.replynum.focus();
              return false;
           }
           
		   if(document.frmMain.replynum.value>250||document.frmMain.hits.value<0){
              msg.innerHTML="<br><font color='red'>提示:主题回复次数范围为0~250</font>";
              document.frmMain.replynum.focus();
              return false;
           }
           
           if(document.frmMain.forumid.value==""){            
              msg.innerHTML="<br><font color='red'>提示:请选择主题默认所在论坛</font>"    
              document.frmMain.forumid.focus();
              return false;
           }
            return true;  
        }
		
			function Init(){
				getSelected(document.frmMain.forumid.options,'<%=topicData.getForumid()%>');
				getSelected(document.frmMain.isbest.options,'<%=topicData.isBest()%>');
				getSelected(document.frmMain.ishighlight.options,'<%=topicData.isHighlight()%>');
				getSelected(document.frmMain.istop.options,'<%=topicData.isTop()%>');
			}
		</script>
	</head>

	<body onload="Init()">
		<form name="frmMain" action="TopicUpdateServlet" method="post" onSubmit="return validate();">
			<table class="navigation" style="width:98%" align="center">
				<tr>
					<td>
						当前位置: 主题管理-->操作-->
						<font color="red"><%=processMod[opType - 1]%></font>
					</td>
				</tr>
			</table>
			<br>
			<table style="width:90%;" align="center">
				<div class="DialogBody">
					<div class="formArea">
						<div id="errormsg" class="DialogMsg"></div>
						<p>
							&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;主题名称:
							<input type="text" name="topictitle" style="width:200px" maxlength="60" value="<%=topicData.getTopicTitle()%>">
							(提示:可以名称前后加上符号,1~60字符)
						<p>
							主题所在论坛:
							<select name="forumid">
							<option value="">请选择</option>
							<%	if (forumList == null) {
									forumList = new ArrayList();
									System.out.println("forumList为空");
								}
								it1 = forumList.iterator();
								if (it1 != null) {
									while (it1.hasNext()) {
										ForumVo forumData = (ForumVo) (it1.next());
							%>
							<option value="<%=forumData.getForumID()%>"><%=forumData.getForumName()%></option>
							<%}}%>
							</select> (此选项可以转移主题)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<p>
							&nbsp;主题作者:
							<input type="text" name="authorname" style="width:200px" maxlength="20" value="<%=topicData.getAuthorname()%>" disabled="disabled">
							(提示:作者不可以修改,1~20字符)
						<p>
							&nbsp;发表时间:
							<input type="text" name="topictime" style="width:200px" value="<%=topicData.getTopicDate()%>" disabled="disabled">
							(提示:时间不可以修改)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<p>
							查看次数:
							<input type="text" name="hits" style="width:150px" value="<%=topicData.getHits()%>">
							(主题被浏览的总次数,整数0~250)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<p>
							回复次数:
							<input type="text" name="replynum" style="width:150px" value="<%=topicData.getPostNum()%>">
							(主题被回复的总次数,整数0~250)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<p>
							是否精华:
								<select name="isbest">
									<option value="0">否	</option>
									<option value="1" style="color:red">是</option>
								</select> (设置本主题为精华主题) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<p>
							是否高亮:
								<select name="ishighlight">
									<option value="0">否	</option>
									<option value="1" style="color:red">是</option>
								</select>(设置本主题为高亮主题) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						
						<p>
							是否置顶:
							<select name="istop">
									<option value="0">否	</option>
									<option value="1" style="color:red">是	</option>
							</select>(设置本主题为置顶主题) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<p>
							<input type="submit" name="submit" class="button" value=" 确定 " onclick="validate();">
							<input type="button" name="button" class="button" value=" 取消 " onclick="preReturn();">
						<p>
							<br>
					</div>
				</div>
			</table>
			<input type="hidden" name="topicid" value="<%=topicData.getTopicid()%>">
			<input type="hidden" name="lastforumid"  value="<%= topicData.getForumid()%>">
			<input type="hidden" name="opType" value="<%=opType%>">
			<input type="hidden" name="queryPage" value="<%=queryPage%>">
			<input type="hidden" name="forumSelect" value="<%=forumSelect%>">
		</form>
	</body>
</html>
